// 11/04/2009 Dennis
// This form has a listbox (no other controls available at this point)
// and a simple query to fill the listbox with items
// it's more just an example how to build a form based on the Form class
// Have the query code in the setActive method and the (missing) event handling method
// Create all controls in the constructor. Don't forget to call addControl(...) after creating the control
class ListForm extends Form
{
  ListBox listbox;
  public ListForm()
  {
    // Create listbox
    listbox = new ListBox();
    listbox.x = 100;
    listbox.y = 50;
    listbox.width = 600;
    listbox.height = 500;
    listbox.header.add(new ListBoxHeader("Track Title", 50));
    listbox.header.add(new ListBoxHeader("Artist", 25));
    listbox.header.add(new ListBoxHeader("Album", 25));
    addControl(listbox);
    
    // Create other controls here...
    
    Label lbl = new Label();
    lbl.x = 50;
    lbl.y = 10;
    lbl.forecolor = color(255);
    lbl.label = "Form 1";
    addControl(lbl);
  }
  
  public void processEvent(Control c)
  {
    if(c == listbox)
      System.out.println("listbox event");
  }
  
  public void setActive()
  {
    /*ArrayList query = db.queryPlayed(null, null, null, null, null, null);
    for(int i = 0; i < query.size(); i++)
    {
      Played p = (Played)query.get(i);
      ListBoxItem lbi = new ListBoxItem();
      lbi.labels.add(p.track.title);
      lbi.labels.add(p.track.artist);
      lbi.labels.add(p.track.album);
      listbox.items.add(lbi);
    }*/
  }
}
